<template>
  <div class="home">
    <el-container>
      <el-header>
        <el-row :gutter="20">
          <el-col :span="4">
            <img src="../assets/logo.png" alt="" class="logo" />
          </el-col>
          <el-col :span="16">
            <h2>后台管理系统</h2>
          </el-col>
          <el-col :span="4" class="col-btn">
            <el-button type="primary" @click="delToken">退出登录</el-button>
          </el-col>
        </el-row>
      </el-header>
      <el-container>
        <el-aside width="200px">
          <el-menu active-text-color="#ffd04b" background-color="#545c64" class="el-menu-vertical-demo"
            text-color="#fff" router :default-active="active">
            <el-menu-item v-for="item in list" :key="item.path" :index="item.path">
              <el-icon>
                <icon-menu />
              </el-icon>
              <span>{{ item.meta.title }}</span>
            </el-menu-item>
          </el-menu>
        </el-aside>
        <el-main>
          <router-view />
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>

<script lang="ts" setup>
import { useRouter, useRoute } from 'vue-router'
import { Menu as IconMenu } from '@element-plus/icons-vue'
const router = useRouter();
const route = useRoute();
const active = route.path;
const list = router.getRoutes().filter(item => item.meta.isShow);
const delToken = () => {
  localStorage.removeItem('token');
  router.replace('/login');
}
</script>
<style lang="scss">
.el-header {
  height: 80px;
  background: rgb(88, 88, 88);

  .logo {
    height: 80px;
  }

  h2,
  .quit-login {
    text-align: center;
    height: 80px;
    line-height: 80px;
    color: #fff;
  }

  .col-btn {
    height: 80px;
    line-height: 80px;
  }
}

.el-aside {
  .el-menu {
    height: calc(100vh - 80px);
  }
}
</style>